import random
i = 5000
a = 1
while a:
    num = int(input("请输入一个1-100的数字："))
    Rnum = random.randint(1, 100)
    while num != Rnum and i > 500:
        if num > Rnum:
            print("大了")
            i = i - 500
            print("当前剩余金币：", i)
        else:
            print("小了")
            i = i - 500
            print("当前剩余金币：", i)
        num = int(input("请输入一个1-100的数字："))
    if num == Rnum:
        print("恭喜猜中，奖励3000金币，本轮幸运数字：", Rnum)
        i = i + 3000
        print("当前剩余金币：", i)
        a = bool(input("请问是否继续游戏，选择1继续，选择0游戏结束:"))
        continue
    else:
        print("余额不足，本轮幸运数字：", Rnum)
        break
print("游戏结束")





